package com.cpic.rxjava;

public class CreateEmitter<T> implements Emitter<T> {
    Observer<T> observer;
    // observable 与 emitter 通过 ObservableOnSubscribe 绑定
    // emitter 与 observer 通过 observable 绑定
    public CreateEmitter(Observer<T> observer) {
        this.observer = observer;
    }

    @Override
    public void onNext(T t) {
        observer.onNext(t);
    }

    @Override
    public void onError(Throwable throwable) {
        observer.onError(throwable);
    }

//    @Override
//    public void onSubcribe() {
//        observer.onSubcribe();
//    }

    @Override
    public void onComplete() {
        observer.onComplete();
    }
}
